
import  urllib.request

def create_proxy_handler():

    url = "https://blog.csdn.net/m0_37499059/article/details/79003731"

    # 添加代理 书写格式
    # ({"http" : "http://ahad-haam:3128"}
    proxy = {
        # 免费的写法
        # "http":"http://171.39.28.208:8123",
        "http":"115.46.79.142:8000"

        # 付费的代理
        # "http":"xiaoming:123@115.46.79.142:8000"
    }

    # 代理的处理器
    proxy_handler = urllib.request.ProxyHandler(proxy)

    # 自己的opener
    opener = urllib.request.build_opener(proxy_handler)

    # 带着代理IP 去发送请求  open
    data = opener.open(url).read()
    print(data)

create_proxy_handler()



